﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web;
namespace OneShoppingUtility
{
    public class UtilityDataBind
    {

        public static void DropDownListBindData<T>(ref DropDownList d, List<T> list,
        string dataTextField, string dataValueField, string text) where T : class
        {
            d.DataSource = list;
            d.DataTextField = dataTextField;
            d.DataValueField = dataValueField;
            d.DataBind();
            d.Items.Add(new ListItem("---请选择" + text + "---", "-1"));
            d.SelectedValue = "-1";
        }

        public static void DropDownListBind<T>(ref DropDownList d, List<T> list,
        string dataTextField, string dataValueField, string text,string textvalue) where T : class
        {
            
            d.DataSource = list;
            d.DataTextField = dataTextField;
            d.DataValueField = dataValueField;
            d.DataBind();
            d.Items.Add(new ListItem(text, textvalue));
            d.SelectedValue = textvalue;
        }
    }
}
